package org.teamh.connection.handler;

import org.teamh.game.Start;
import org.teamh.logic.lobby.Player;

public class PlayerHandler extends MasterHandler {

	public PlayerHandler(Start start) {
		super(start);
	}

	public boolean handleMsg(String line) {

		String playerName;
		String team;

		if (line.startsWith("USER") && line.contains("STATE=LOBBY")) {

			String[] str = line.split(" ");
			playerName = str[1].substring(5);
			team = str[2].substring(5);

			Player player = new Player(playerName, team);
			start.getModel().addPlayer(player);
			
			return true;
		} else {
			return false;
		}
	}

}
